lis = [1, -2, 3, 5, -1, 6, -7, 9]
s, m = 0, 0
for i in lis:
    s += i
    if s < 0:
        s = 0
    else:
        if s > m:
            m = s
print(m)
